Skip to content

Claim the shutdown on Quit and the --for expiry, not only on a signal [patch] - #84

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/claim-shutdown-on-quit-and-expiry-80
Nov 11, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/claim-shutdown-on-quit-and-expiry-80

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #80

What was wrong

Only TrayApplication.RequestShutdown, the signal path, set shutdownRequested. The Quit item and the --for expiry timer called Shutdown() directly. After either one, the first Ctrl+C or SIGTERM still found the flag clear, so ShutdownSignals cancelled the signal. It then posted a second shutdown to a UI thread that might already be blocked in a hung OnStop. Under systemd, a --for run then waited out TimeoutStopSec and was SIGKILLed. A --no-tray run exits on the first SIGTERM.

Change

Tests

  • ASignalAfterQuit_IsNotCancelled now drives OnQuitRequested, the real Quit path, instead of RequestShutdown. It checks that the run ended once and the following SIGHUP has Cancel == false.
  • New ASignalAfterTheDurationExpires_IsNotCancelled: the same check for the expiry, followed by a SIGTERM.
  • New QuitAfterASignal_DoesNotEndTheRunAgain.
  • With the claim reverted, all three fail.
  • Full suite on Linux / .NET 10: 193 passed, 1 skipped. scripts/check-tray-signals.sh was not run, because it needs a desktop session.

Generated by Claude Code

…a signal

Only RequestShutdown set shutdownRequested. The Quit item and the --for timer
called Shutdown() directly, so after either one the first Ctrl+C or SIGTERM
was still cancelled and queued a second shutdown behind a stop action that
might be hung; under systemd a --for run then waited out TimeoutStopSec.
Quit and the expiry now claim the flag before ending the run, so the next
signal gets its default handling, as it does in the console mode.

ASignalAfterQuit_IsNotCancelled drives the Quit handler instead of
RequestShutdown, and the expiry has its own test.

Fixes #80

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW31r4TeF4cogSkLxEi
@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

After clicking Quit or the --for expiry, a Ctrl+C/SIGTERM during a hung OnStop is still swallowed: only RequestShutdown marks the shutdown as under way

2 participants